package com.bsfcs.rag.enums;

import org.springframework.util.StringUtils;

public enum TaskPriority {
    LOW("0", "最低"),
    MEDIUM("1", "较低"),
    NORMAL("2", "普通"),
    HIGH("3", "较高"),
    URGENT("4", "最高");

    private final String code;
    private final String displayName;

    TaskPriority(String code, String displayName) {
        this.code = code;
        this.displayName = displayName;
    }

    public String getCode() {
        return code;
    }

    public String getDisplayName() {
        return displayName;
    }

    public static TaskPriority fromCode(String code) {
        if (!StringUtils.hasText(code)) {
            return null;
        }
        for (TaskPriority priority : TaskPriority.values()) {
            if (priority.getCode().equals(code)) {
                return priority;
            }
        }
        return TaskPriority.NORMAL;
    }
}
